//
//  FoundationCustom.swift
//  FoundationCustom
//
//  Created by ZhouJiatao on 2018/10/26.
//  Copyright © 2018 Unknow. All rights reserved.
//

import Foundation


/// 返回本地化字符串
public func CBLocalizedString(_ key: CBLocalizedKey, comment: String) -> String {
    
    return CBLocalized.shared.dictionary[key.rawValue] ?? key.defaultLocalizedValue

}


public func notEmpty(_ string: String?) -> Bool {
    return !isEmpty(string)
}

public func isEmpty(_ string: String?) -> Bool {
    return (string ?? "").isEmpty
}



/// 如果第一个string为空（nil 或 空字符串），则使用第二个string
///
/// - Parameters:
///   - string: 优先使用的字符串
///   - default: 默认字符串
public func emptyCoalescing(_ string: String?, default value: String) -> String {
    if string == nil || string!.isEmpty {
        return value
    }
        
    return string!
}
